#include "stdafx.h"
#include "drawing_api.h"

bool drawing_intersection(
	float_32 x11, float_32 y11, float_32 x12, float_32 y12,
	float_32 x21, float_32 y21, float_32 x22, float_32 y22,
	float_32 * x, float_32 * y)
{
	float_32 sumx = (y11 - y21) * (x22 - x21) - (x11 - x21) * (y22 - y21);
	float_32 sumy = (x12 - x11) * (y22 - y21) - (y12 - y11) * (x22 - x21);

	if(sumy > -drawing_collinearity_off && sumy < drawing_collinearity_off) 
		return false;

	float_32 scale = sumx / sumy;
	*x = x11 + scale * (x12 - x11);
	*y = y11 + scale * (y12 - y11);
	return true;
}

